#include <stdio.h>
#include <stdlib.h>

int main() 
{
    int n = 0, m = 0, k = 0, i = 0, j = 0;
    scanf("%d %d", &n, &m);
    int* a = (int*)malloc(sizeof(int) * n);
    int* b = (int*)malloc(sizeof(int) * m);
    for(i = 0;i < n;i++)
    {
        scanf("%d", &a[i]);
    } 
    for(i = 0;i < m;i++)
    {
        scanf("%d", &b[i]);
    }
    i = 0;
    for(k = 0;k < m+n;k++)
    {
        if(i == n)
        {
            printf("%d ", b[j]);
            j++;
            continue;
        }
        if(j == m)
        {
            printf("%d ", a[i]);
            i++;
            continue;
        }
        if(a[i] >= b[j])
        {
            printf("%d ", b[j]);
            j++;
        }
        else 
        {
            printf("%d ", a[i]);
            i++;
        }
    }
    return 0;
}